<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>#div1{width:100px;height:100px;background-color: #ccc;position: absolute;}</style>
    <script>
        document.onkeydown=function(ev){
          var oEvent=ev||event;
          var oDiv=document.getElementById('div1');
          if(oEvent.keyCode==37){
           oDiv.style.left=oDiv.offsetLeft-10+'px';
          }
          else if(oEvent.keyCode==39){
           oDiv.style.left=oDiv.offsetLeft+10+'px';
          }
        };
    </script>
</head>
<body>
<div id="div1"></div>
</body>
</html>